home *** CD-ROM | disk | FTP | other *** search
- Path: shellx.best.com!not-for-mail
- From: smurman@shellx.best.com (Scott Murman)
- Newsgroups: comp.lang.c++,comp.unix.solaris
- Subject: Working with Sun's CC-4.1
- Date: 6 Apr 1996 14:27:12 -0800
- Organization: Soga Technologies
- Distribution: inet
- Message-ID: <4k6r40$5qv@shellx.best.com>
- Reply-To: Scott Murman <smurman@best.com>
- NNTP-Posting-Host: shellx.best.com
-
-
- I've used gcc-2.7 as my C++ compiler for some time. I've now got
- Sun's CC-4.1 to work with. There are some problems with Sun's
- compiler that I'm trying to work around. The first seems to be a
- restriction on the return type allowed when over loading
- operator->(). The second problem is that Sun hasn't implemented the
- draft standard revision whereby virtual methods can have a different
- return type in the derived class. Here's an example code snippet that
- won't compile for me
-
- template <class T>
- class Example {
-
- public:
- Example(const T& v) : _Value(v) {};
-
- // this gives me "Error: Cannot have a return type of T* for operator->()"
-
- T* operator->(void) const {
- return(&_Value);
- }
-
- virtual Example* PointerMethod(void) const {
- return(this);
- }
-
- private:
-
- T _Value;
- };
-
- In a class derived from Example, PointerMethod is still required to
- return and Example* which is against the C++ draft standard.
-
- Does anyone have methods to work around these problems/limitations?
- Have I messed up something in my compilation to get these problems?
-
- Scott
-